< previous page page_65 next page >

Page 65
Place this code in the cmdISBN_Click event:
Private Sub cmdISBN_Click()
    '
    ' set for ISBN index
    '
    strIndex = "PrimaryKey"
    strField = "ISBN"
    LoadList
    '
End Sub
Place this code in the cmdPublisher_Click event:
Private Sub cmdPublisher_Click()
    '
    ' set for PubID index
    '
    strIndex = "PubID"
    strField = "PubID"
    LoadList
    '
End Sub
The Seek routine shown in Listing 3.13 calls an input box to prompt the user for a search value, performs the seek, and reports the results of the search. The routine first checks to see whether the user has filled the list box by selecting an index. If the list box contains data, the routine calls the Visual Basic InputBox function to get user input, and then invokes the Seek method of the table object. If the record is not found, you see a Seek Failed message. If you entered a record that is on file, you see a Record Found message.
Type.gifListing 3.13. Coding the Seek routine for TBSEEK.VBP.
Private Sub cmdSeek_Click()
    '
    ' perform table seek
    '
    Dim strSeek As String
    '
    If lstRecordset.ListCount = 0 Then
        MsgBox "Select an Index First!", vbExclamation, "Missing Index"
    Else
        strSeek = InputBox("Enter a Seek value for " & strField)
        rs.Seek "=", strSeek
        If rs.NoMatch = True Then
            MsgBox strSeek & " not in table", vbCritical, "Seek Failed"
        Else
            MsgBox rs.Fields("Title"), vbInformation, "Record Found"
        End If
    End If
    '
End Sub

 
< previous page page_65 next page >

If you like this book, buy it!